package mmoon.mmoonstory.commands;

import mmoon.mmoonstory.EasyCommand;
import mmoon.mmoonstory.interfaces.InitCommand;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;

public class CommandGM extends CommandBase implements InitCommand {
    public CommandGM() {
        this.init();
    }

    @Override
    public String getName() {
        return "gm";
    }

    @Override
    public String getUsage(ICommandSender sender) {
        return "/gm [0-3]";
    }

    @Override
    public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
        if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
            if (args.length == 1) {
                EasyCommand.gameMode(player, Integer.parseInt(args[0]));
            } else {
                throw new WrongUsageException(this.getUsage(sender));
            }
        }
    }
}
